package com.wyp168.leetcode;

public class yiweiciString {
    public static void main(String[] args) {
        System.out.println(isTrue("wang", "wnag"));
    }

    public static boolean isTrue(String s, String t) {
        if(s.length() != t.length()) {
            return  false;
        }
        char[] cs = s.toCharArray();
        char[] ct = t.toCharArray();

        int [] asc = new int[26];
        int count = 0;

        for(int i=0; i< cs.length;i++) {
            if(++asc[cs[i]-'a'] == 1) {
                count ++;
            }
            if(--asc[ct[i]-'a'] == 0) {
                count --;
            }
        }
        return count == 0;
    }
}
